//
// Created by 紫霄 on 2020/4/7.
//

#ifndef LEETCODE_06_H
#define LEETCODE_06_H
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
#include <stack>
#include <vector>
using namespace std;

struct ListNode {
  int val;
  ListNode *next;
  ListNode(int x) : val(x), next(NULL) {}
};
class Solution {
public:
  vector<int> reversePrint(ListNode *head) {
    ListNode *temp;
    vector<int> a;
    stack<int> b;
    temp = head;
    while (temp) {
      b.push(temp->val);
      temp = temp->next;
    }
    while (!b.empty()) {
      a.push_back(b.top());
      b.pop();
    }
    return a;
  }
};
#endif // LEETCODE_06_H
